import { Checkbox } from '@antmjs/vantui';
import { Text } from '@tarojs/components';
import Taro from '@tarojs/taro';
import { useState } from 'react';

export function useAgree() {
  const [agree, setAgree] = useState<boolean>(false);

  function renderNode() {
    return (
      <Checkbox
        className=' my-4 w-[625px]'
        style={{
          //@ts-ignore
          '--checkbox-label-color': '#fff',
          '--checkbox-border-color': '#fff',
          alignItems: 'flex-start',
        }}
        value={agree}
        onChange={(e) => {
          setAgree(e.detail);
        }}
      >
        <Text>我已认真阅读并同意企业服务平台</Text>
        <Text
          style={{ color: '#F6AD3C' }}
          onClick={(e) => {
            e.stopPropagation();
            Taro.navigateTo({ url: `/pages/rules` });
          }}
        >
          《会员章程》
        </Text>
      </Checkbox>
    );
  }

  return { renderNode, agree };
}
